package games;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.IOException;
import java.net.URL;

import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

public class Instructions extends Game {
	/**
	 * 
	 */
	private static final long serialVersionUID=1L;

	private static final String NAME="Instructions";
	
	URL page;
	
	public Instructions(Runner runner,String pageStr) {
		super(runner,NAME);
		page=Instructions.class.getResource("instructions/"+pageStr);
	}
	public void start() {}
	public void init() {
		setLayout(new BorderLayout());
		
		JEditorPane editorPane = new JEditorPane();
		editorPane.setEditable(false);
		if (page != null) {
		    try {
		        editorPane.setPage(page);
		    } catch (IOException e) {
		        System.err.println("Attempted to read a bad URL: "+page);
		    }
		} else {
		    System.err.println("Couldn't find file: Instructions.html");
		}

		//Put the editor pane in a scroll pane.
		JScrollPane editorScrollPane = new JScrollPane(editorPane);
		editorScrollPane.setPreferredSize(new Dimension(600,300));
		
		header=new JPanel(new BorderLayout());
		header.add(BorderLayout.NORTH,editorScrollPane);
		add(BorderLayout.NORTH,header);
		
		go=new Painter("go","Click to Continue");
		footer=new JPanel(new BorderLayout());
		footer.add(BorderLayout.EAST,go);
		
		add(BorderLayout.SOUTH,footer);
		
		hmmm(NAME);
	}

}
